//
//  HCHomeViewController.m
//  HappyChildren
//
//  Created by WillyZhao on 2016/12/16.
//  Copyright © 2016年 WillyZhao. All rights reserved.
//

#import "HCHomeViewController.h"

#import "YBKPPTVC.h"
#import "HCHomeMiddleView.h"
#import "HCSanimationView.h"
#import "HCContentButton.h"
#import "HCHomeBottomView.h"
#import "AppDelegate.h"

#import "HCHomeNewsModel.h"

#import "HCGoodsListModel.h"
#import "XFWkwebView.h"
#import <AFNetworking.h>
#import "HCHomeWkWebView.h"
#import "HCPopLoadingView.h"

#import "HCHomeAlGrowModel.h"
#import "HCAlGrowCollectionViewCell.h"
#import "HCNewsCenterDetailController.h"
#import "HCSSView.h"
#import "HCHomeProjectView.h"
#import "HCHomeBrandPreferenceView.h"
#import "HCHomeCarefullyChooseView.h"

@interface HCHomeViewController () <HCHomeBottomViewSizeDataSource,UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout,HCSSViewClickDelegate,HCHomeWkWebViewHeight,HCSanimationViewClicked,HCHomeMiddleViewDelegate> {
    __weak  UIView *pptView;
    HCHomeAlGrowModel *alGrowModel;             //首页推荐成长相册model
    YBKPPTVC *pptvc;//banner图
    UIScrollView *contentScrollView;
    HCHomeBottomView *bottomView;
    NSMutableArray *images;
    
    HCHomeNewsModel *newsModel;
    HCSanimationView *an;
    UIView *vc;
    
    HCGoodsListModel *goodsModel;
    
    HCHomeWkWebView *web;
    MBProgressHUD *homeHud;
    UICollectionView *alGrowCollection_;
    UICollectionView *homeVrCollection_;
    HCSSView *ssView;
    NSMutableArray *naNamesArray;
    UIImageView *advertiseImageView1;
}

@property (nonatomic, strong)  NSArray *projectsArray;
@property (nonatomic, strong)  NSArray *discountArray;
@property (nonatomic, strong)  NSArray *careChooseArray;
@property (nonatomic, strong)  NSArray *advertiseImages;
@property (nonatomic, strong)  HCHomeBrandPreferenceView *preferenceView;//品牌特惠
@property (nonatomic, strong)  HCHomeCarefullyChooseView *careChooseView; //精心挑选
@property (nonatomic, strong)  HCHomeProjectView *projectView; //项目展示

@end

@implementation HCHomeViewController

-(void)viewWillAppear:(BOOL)animated {
    
    [super viewWillAppear:animated];
    self.dataRequest.delegate = self;
    [self.dataRequest postHC_Vipcheck:[NSString stringWithFormat:@"%@",HCGETUSER(@"hcphone")]];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    self.view.backgroundColor = [UIColor redColor];
    self.textTitle = @"首页";
    self.advertiseImages = [NSArray array];
    self.projectsArray = [NSArray array];
    self.discountArray = [NSArray array];
    self.careChooseArray = [NSArray array];
    //页面加载
    CGRect frame =  [self initBannerPic]; //banner图
    frame = [self initCollectionView:frame]; //中间工具栏
    frame = [self initializeScrollAnimationView:frame]; //新闻中心
    frame = [self initAdvertiseImageView1:frame]; //广告图1
    frame = [self initProjectView:frame]; //项目展示
    frame = [self initBrandPreferenceView:frame]; //品牌特惠
    frame = [self initCarefullyChoosedView:frame]; //精心挑选

    contentScrollView.contentSize = CGSizeMake(Screen_width, CGRectGetMaxY(frame)+10);
}

#pragma mark 儿童乐园，水系乐园等
-(CGRect)initSecondCollection:(CGRect)frame {
    UIView *vc_vv = [[UIView alloc] initWithFrame:CGRectMake(0,frame.size.height+frame.origin.y, frame.size.width, frame.size.height+1)];
    vc_vv.backgroundColor = [UIColor whiteColor];
    [contentScrollView addSubview:vc_vv];
    
    UIView *lineV = [[UIView alloc] initWithFrame:CGRectMake(4, 0, vc_vv.frame.size.width-8, .5f)];
    lineV.backgroundColor = YBKRGBCOLOR(241, 241, 241, 1);
    [vc_vv addSubview:lineV];
    
#pragma mark 第二排collection
    ssView = [[HCSSView alloc] initWithFrame:CGRectMake(0, lineV.frame.size.height, vc_vv.frame.size.width, vc_vv.frame.size.height - lineV.frame.size.height)];
    ssView.delegate = self;
    ssView.backgroundColor = [UIColor whiteColor];
    [vc_vv addSubview:ssView];
    
    return vc_vv.frame;
}

#pragma mark 第二排点击事件
-(void)hcSSViewClicked:(NSIndexPath *)indexPath {
    //第二排图标点击
    //TODO
    
    if (naNamesArray.count>0) {
        NSMutableArray *ac = [NSMutableArray array];
        for (int i = 0; i<naNamesArray.count; i++) {
            [ac addObject:[NSString stringWithFormat:@"%@",naNamesArray[i][@"name"]]];
        }
        
        [self pushChildrenViewController:@"HCNvaDetailViewController" parameterObject:naNamesArray dataObject:[NSString stringWithFormat:@"%ld",indexPath.row]];
    }
}

#pragma mark 网络请求返回
-(void)dataRequesterFinish:(DataRequester *)requester requesterWithType:(DataRequestType)aType receiveDictionary:(NSDictionary *)dictionary {
    
    if (aType == HC_NEWS) {
       
        newsModel = [[HCHomeNewsModel alloc] initWithDictionary:dictionary error:nil];
        an.model = newsModel;
        [self.dataRequest postHC_BannerGet];
        
    }else if(aType == HC_HOMEVIPCHECK_TYPE){
       
        [self.dataRequest getNews];
        if ([dictionary[@"vip"] integerValue] == 200) {
            HCUSERDEFUALTS(@"yes", @"hcvip");
        }else{
            HCUSERDEFUALTS(@"no", @"hcvip");
        }
    }else if (aType == HC_GETBANNERSS_TYPE) {
        
        NSArray *ar = [NSArray arrayWithArray:dictionary[@"pic"]];
        pptvc.showModelArray = ar;
        [self.dataRequest post_HCHomeAdvertiseImages];
        
    }else if(aType == HC_HOMEADVERTISES_TYPE){
        
        if (dictionary) {
            
            self.advertiseImages = [dictionary objectForKey:@"pic"];
            [self setAdvertiseImagesWithArray:self.advertiseImages];
            [self.dataRequest post_HCHomeProjectShow];
        }

    }else if(aType == HC_HOMEPROJECTSHOW_TYPE){
        
        if (dictionary) {
            
            self.projectsArray = [dictionary objectForKey:@"sp_offer"];
            self.projectView.projectArray = self.projectsArray;
            
            [self.dataRequest post_HCHomeDiscountShow];
        }
        
    }else if (aType == HC_HOMEDISCOUNTGOODS_TYPE){
       
        if (dictionary) {
            
            self.discountArray = [dictionary objectForKey:@"goods"];
            self.preferenceView.goodsArray = self.discountArray;
        }
        [self.dataRequest post_HCHomeCarefullyChoose];
    }
    else if (aType == HC_HOMECAREFULLYCHOOSE_TYPE) {
    
        if (dictionary) {
            
            self.careChooseArray = [dictionary objectForKey:@"goods"];
            self.careChooseView.goodsArray = self.careChooseArray;
        }
    }
}

- (void)setAdvertiseImagesWithArray:(NSArray *)advertise {

    for (int i = 0; i < advertise.count; i++) {
        
        if (i == 0) {
            
            [advertiseImageView1 sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@",[advertise[i] objectForKey:@"path"]]] placeholderImage:nil];
        }
        if (i == 1) {
         
            self.preferenceView.advertiseImageUrl = [NSString stringWithFormat:@"%@",[advertise[i] objectForKey:@"path"]];
        }
        if (i == 2) {
            
            self.careChooseView.advertiseImageUrl = [NSString stringWithFormat:@"%@",[advertise[i] objectForKey:@"path"]];
        }
    }
}

-(void)dataRequesterFail:(DataRequester *)requester requesterWithType:(DataRequestType)aType receiveErrorDictionary:(NSDictionary *)dictionary {
    if (aType == HC_NEWS) {
        NSLog(@"首页获取新闻失败");
    }
}

#pragma mark 初始化banner图片
-(CGRect)initBannerPic {
    
    contentScrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, self.centerView.frame.size.width, self.centerView.frame.size.height)];
    //    contentScrollView.scrollEnabled = NO;
    contentScrollView.showsVerticalScrollIndicator = NO;
    [self.centerView addSubview:contentScrollView];
    pptvc = [[YBKPPTVC alloc] init];
    
    __weak YBKPPTVC *p= pptvc;
    pptvc.clickBlock = ^(HCHomeBannerModel *model) {
        NSLog(@"点击了");
    };
    pptvc.scrollBlock = ^(NSInteger m) {
        p.pptPageControl.currentPage = m;
    };
    //这里-20是一个bug
    pptvc.view.frame=CGRectMake(0, 0,self.centerView.bounds.size.width, YBKAdaptiveH(160));
    pptView=pptvc.view;
    pptvc.view.backgroundColor = [UIColor lightGrayColor];
    [self addChildViewController:pptvc];
    [pptvc didMoveToParentViewController:self];
    [contentScrollView addSubview:pptvc.view];
    return pptvc.view.frame;
}

//重置页面高度
-(void)hc_homeWkHeight:(CGFloat)height {
    
    web.frame = CGRectMake(web.frame.origin.x, web.frame.origin.y, web.frame.size.width, height);
    web.wkWebView.frame = CGRectMake(0, 0, web.frame.size.width, height);
    
    contentScrollView.contentSize = CGSizeMake(self.centerView.frame.size.width, web.frame.origin.y+web.frame.size.height+10);
    [homeHud hide:YES];
}

#pragma mark 成长相册推荐
//初始化成长相册推荐
-(void)alGrothRepain{
    
    vc = [[UIView alloc] initWithFrame:CGRectMake(0, an.frame.origin.y+3+an.frame.size.height, self.centerView.frame.size.width, YBKAdaptiveH(180))];
    vc.backgroundColor = [UIColor whiteColor];
    [contentScrollView addSubview:vc];
    
    UICollectionViewFlowLayout *flow = [[UICollectionViewFlowLayout alloc] init];
    flow.minimumLineSpacing = 10;
    flow.minimumInteritemSpacing = 10;
    flow.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    
    alGrowCollection_ = [[UICollectionView alloc] initWithFrame:CGRectMake(0, YBKAdaptiveH(30), self.centerView.frame.size.width, YBKAdaptiveH(150)) collectionViewLayout:flow];
    alGrowCollection_.delegate = self;
    alGrowCollection_.dataSource = self;
    alGrowCollection_.tag = 1;
    alGrowCollection_.showsHorizontalScrollIndicator = NO;
    alGrowCollection_.backgroundColor = [UIColor whiteColor];
    [vc addSubview:alGrowCollection_];
    [alGrowCollection_ registerNib:[UINib nibWithNibName:@"HCAlGrowCollectionViewCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"cellalg"];
    
    UIImage *image = [UIImage imageNamed:@"成长相册推荐"];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
    imageView.frame = CGRectMake((self.centerView.frame.size.width - image.size.width)/2.0, (YBKAdaptiveH(30) - image.size.height)/2.0+YBKAdaptiveH(2), image.size.width, image.size.height);
    [vc addSubview:imageView];
}

#pragma mark VR按钮
-(void)initVRaBOUT {
    
    UIView *vgf = [[UIView alloc] initWithFrame:CGRectMake(0, vc.frame.origin.y+vc.frame.size.height+3, self.centerView.frame.size.width, YBKAdaptiveH(180))];
    vgf.backgroundColor = [UIColor whiteColor];
    [contentScrollView addSubview:vgf];
    
    UIImage *image = [UIImage imageNamed:@"VR展示"];
    UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
    imageView.frame = CGRectMake((self.centerView.frame.size.width - image.size.width)/2.0, (YBKAdaptiveH(30) - image.size.height)/2.0+YBKAdaptiveH(2), image.size.width, image.size.height);
    [vgf addSubview:imageView];
    
    images = [NSMutableArray array];
    
    for (int i = 0; i<4; i++) {
        UIImage *image = [UIImage imageNamed:[NSString stringWithFormat:@"VR%d",i]];
        [images addObject:image];
    }
    
    UICollectionViewFlowLayout *flow = [[UICollectionViewFlowLayout alloc] init];
    flow.minimumLineSpacing = 10;
    flow.minimumInteritemSpacing = 10;
    flow.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    
    homeVrCollection_ = [[UICollectionView alloc] initWithFrame:CGRectMake(0, YBKAdaptiveH(30), self.centerView.frame.size.width, YBKAdaptiveH(150)) collectionViewLayout:flow];
    homeVrCollection_.delegate = self;
    homeVrCollection_.dataSource = self;
    homeVrCollection_.tag = 2;
    homeVrCollection_.showsHorizontalScrollIndicator = NO;
    homeVrCollection_.backgroundColor = [UIColor whiteColor];
    [vgf addSubview:homeVrCollection_];
    
    [homeVrCollection_ registerNib:[UINib nibWithNibName:@"HCAlGrowCollectionViewCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"cellalg"];
    
}

-(void)VRButtonAction:(UIButton *)btn {
    NSLog(@"VR");
    [self pushChildrenViewController:@"HCVRViewController" parameterObject:nil dataObject:nil];
}

#pragma mark UICollectionDelegate
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    if (collectionView.tag == 1) {
        if (alGrowModel) {
            return alGrowModel.grow_show.count;
        }else{
            return 0;
        }
    }else{
        return images.count;
    }
}

-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
    return 1;
}

-(CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {
    if (collectionView.tag == 1) {
        return CGSizeMake(YBKAdaptiveH(220), YBKAdaptiveH(140));
    }else{
        if (indexPath.row == 0) {
            return CGSizeMake(YBKAdaptiveH(140), YBKAdaptiveH(140));
        }else{
            return CGSizeMake(YBKAdaptiveH(220), YBKAdaptiveH(140));
        }
    }
}

-(UIEdgeInsets)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout *)collectionViewLayout insetForSectionAtIndex:(NSInteger)section {
    return UIEdgeInsetsMake(0, 10, 0, 10);
}

-(__kindof UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
   
    if (collectionView.tag == 1) {
        HCAlGrowCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cellalg" forIndexPath:indexPath];
        cell.backgroundColor = [UIColor whiteColor];
        
        if (alGrowModel) {
            HCHomeAlGrowData *data = alGrowModel.grow_show[indexPath.row];
            cell.model = data;
        }
        
        return cell;
    }else{
        HCAlGrowCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cellalg" forIndexPath:indexPath];
        cell.alName.hidden = YES;
        cell.alHeadIMG.hidden = YES;
        cell.contentImageViewSS.image = images[indexPath.row];
        cell.backgroundColor = [UIColor blackColor];
        return cell;
    }
}

-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath {
    
    [collectionView deselectItemAtIndexPath:indexPath animated:YES];
    if (collectionView.tag == 1) {
        HCHomeAlGrowData *data = alGrowModel.grow_show[indexPath.row];
        [self pushChildrenViewController:@"HCALDetailViewController" parameterObject:data.url dataObject:nil];
    }else{
        [self pushChildrenViewController:@"HCVRViewController" parameterObject:nil dataObject:nil];
    }
}

//传值跳转
-(void)hc_homeWKClicked:(NSString *)url {
    
    XFWkwebView *wkWeb = [[XFWkwebView alloc] init];
    [wkWeb loadWebURLSring:url];
    [self.navigationController pushViewController:wkWeb animated:YES];
}

-(void)initWkWebView:(CGRect)frame {
    
    bottomView = [[HCHomeBottomView alloc] initWithFrame:CGRectMake(0, frame.origin.y+frame.size.height+3+YBKAdaptiveH(183)+YBKAdaptiveH(183), self.centerView.frame.size.width, self.centerView.frame.size.height)];
    bottomView.dataSource = self;
    
    [contentScrollView addSubview:bottomView];
}

#pragma mark 商品列表点击
-(void)goodsViewClicked:(NSIndexPath *)indexPath {
    NSLog(@"商品点击了");
    
    HCGoodsListData *data = goodsModel.goods[indexPath.row];
    
    [self pushChildrenViewController:@"HCGGoodsDetailViewController" parameterObject:data dataObject:data.url];
}

-(CGRect)initCollectionView:(CGRect)frame {
    HCHomeMiddleView *collectionView = [[HCHomeMiddleView alloc] initWithFrame:CGRectMake(0, frame.origin.y+frame.size.height, frame.size.width, YBKAdaptiveH(72))];
    collectionView.delegate = self;
    [contentScrollView addSubview:collectionView];
    return collectionView.frame;
    
}
-(CGRect)initializeScrollAnimationView:(CGRect)frame {
    an = [[HCSanimationView alloc] initWithFrame:CGRectMake(0, frame.origin.y+frame.size.height+3, YBKWinFrame.size.width, YBKAdaptiveH(60))];
    an.delegate = self;
    [contentScrollView addSubview:an];
    return an.frame;
}

#pragma mark -- 广告图1
- (CGRect)initAdvertiseImageView1:(CGRect)frame {
    
    advertiseImageView1 = [[UIImageView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(frame)+10, Screen_width, YBKAdaptiveH(100))];
    [contentScrollView addSubview:advertiseImageView1];
    advertiseImageView1.userInteractionEnabled = YES;
    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(advertiseClick)];
    [advertiseImageView1 addGestureRecognizer:tap];
    return advertiseImageView1.frame;
}

#pragma mark -- 项目展示
- (CGRect)initProjectView:(CGRect)frame {

    self.projectView = [[HCHomeProjectView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(frame) + 10, Screen_width, YBKAdaptiveH(123))];
    self.projectView.backgroundColor = [UIColor whiteColor];
    [contentScrollView addSubview:self.projectView];
    
    __weak typeof (self)weakSelf = self;
    [weakSelf.projectView setDidClickProjectImageBlock:^(NSInteger index){
        
        if (index == 1) {
            
            //left
            if (weakSelf.projectsArray.count > 0) {
                
                NSString *url = [NSString stringWithFormat:@"%@",[weakSelf.projectsArray[0] objectForKey:@"url"]];
                [weakSelf pushChildrenViewController:@"HCGoodsDetailViewController" parameterObject:url dataObject:nil];
            }
        }
        if (index == 3) {
            
            //right
            if (weakSelf.projectsArray.count > 2) {
                
                NSString *url = [NSString stringWithFormat:@"%@",[weakSelf.projectsArray[2] objectForKey:@"url"]];
                [weakSelf pushChildrenViewController:@"HCGoodsDetailViewController" parameterObject:url dataObject:nil];
            }
        }
        if (index == 2) {
            
            //center
            if (weakSelf.projectsArray.count > 1) {
                
                NSString *url = [NSString stringWithFormat:@"%@",[weakSelf.projectsArray[1] objectForKey:@"url"]];
                [weakSelf pushChildrenViewController:@"HCGoodsDetailViewController" parameterObject:url dataObject:nil];
            }
        }
    }];
    return self.projectView.frame;
}

//品牌特惠
- (CGRect)initBrandPreferenceView:(CGRect)frame {

    self.preferenceView = [[HCHomeBrandPreferenceView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(frame)+10, Screen_width, YBKAdaptiveH(305))];
    self.preferenceView.backgroundColor = [UIColor whiteColor];
    [contentScrollView addSubview:self.preferenceView];
    
    __weak typeof (self)weakSelf = self;
    [weakSelf.preferenceView setDidClickGoodsBlock:^(NSInteger index){
        
        if (weakSelf.discountArray.count > 0) {
            
            NSString *gid = [NSString stringWithFormat:@"%@",[weakSelf.discountArray[index] objectForKey:@"id"]];
            [weakSelf pushChildrenViewController:@"HCGGoodsDetailViewController" parameterObject:gid dataObject:nil];
        }
    }];
    
    [weakSelf.preferenceView setDidClickAdvertiseBlock:^{
       
        if (weakSelf.advertiseImages.count > 0) {
            
            [weakSelf pushChildrenViewController:@"HCGoodsDetailViewController" parameterObject:[self.advertiseImages[1] objectForKey:@"url"] dataObject:nil];
        }
    }];
    
    return self.preferenceView.frame;
}

//精心挑选
- (CGRect)initCarefullyChoosedView:(CGRect)frame {

    self.careChooseView = [[HCHomeCarefullyChooseView alloc] initWithFrame:CGRectMake(0, CGRectGetMaxY(frame)+10, Screen_width, YBKAdaptiveH(307))];
    self.careChooseView.backgroundColor = [UIColor whiteColor];
    [contentScrollView addSubview:self.careChooseView];
    __weak typeof (self)weakSelf = self;
    [weakSelf.careChooseView setDidClickGoodsBlock:^(NSInteger index){
        
        NSString *gid = [NSString stringWithFormat:@"%@",[weakSelf.careChooseArray[index] objectForKey:@"id"]];
        [weakSelf pushChildrenViewController:@"HCGGoodsDetailViewController" parameterObject:gid dataObject:nil];
    }];
    
    [weakSelf.careChooseView setDidClickAdvertiseblock:^{
       
        if (weakSelf.advertiseImages.count > 0) {
            
            [weakSelf pushChildrenViewController:@"HCGoodsDetailViewController" parameterObject:[self.advertiseImages[2] objectForKey:@"url"] dataObject:nil];
        }
    }];
    
    return self.careChooseView.frame;
}

#pragma mark -- 点击事件
- (void)advertiseClick {

    if (self.advertiseImages.count > 0) {
        
        [self pushChildrenViewController:@"HCGoodsDetailViewController" parameterObject:[self.advertiseImages[0] objectForKey:@"url"] dataObject:nil];
    }
}

-(void)initializeBottomView:(CGRect)frame {
    bottomView = [[HCHomeBottomView alloc] initWithFrame:CGRectMake(0, frame.origin.y+frame.size.height+3, frame.size.width, 200)];
    bottomView.dataSource = self;
    bottomView.collectionScolled = NO;
    [contentScrollView addSubview:bottomView];
}

//#pragma mark HCHomeBottomViewSizeDataSource
-(void)homeBottomViewSize:(CGFloat)height bottomView:(HCHomeBottomView *)homeBottomView {
    bottomView.frame = CGRectMake(0, bottomView.frame.origin.y, bottomView.frame.size.width, height-YBKAdaptiveH(6));
    contentScrollView.contentSize = CGSizeMake(bottomView.frame.size.width, height+bottomView.frame.origin.y);
}

#pragma mark HCHomeMiddleViewDelegate
-(void)middleViewButtonsClicked:(HCHomeMiddleViewClickType)clickStyle {
    
    switch (clickStyle) {
        case HCHomeMiddleViewChest:
            //育儿宝箱
        {
            if (![PublicFunction isNull:HCGETUSER(@"userid")]) {
                if (![PublicFunction isNull:HCGETUSER(@"hcvip")]) {
                
                
                }
     
            }else{
                [XHToast showBottomWithText:@"请先登录"];
            }
        }
            break;
        case HCHomeMiddleViewImages:
            //成长相册
            //            [self pushChildrenViewController:@"HCGrowthAlbumViewController" parameterObject:nil dataObject:nil];
        {
            //            if (![PublicFunction isNull:HCGETUSER(@"hcvip")]) {
            //                if ([[NSString stringWithFormat:@"%@",HCGETUSER(@"hcvip")] isEqualToString:@"yes"]) {
            if (![PublicFunction isNull:HCGETUSER(@"userid")]) {
                [self pushChildrenViewController:@"HCGrowthAlbumViewController" parameterObject:nil dataObject:nil];
            }else{
                [XHToast showBottomWithText:@"请先登录"];
            }
            //                }else{
            //                    [XHToast showBottomWithText:@"请升级为会员"];
            //                }
            //            }
        }
            break;
        case HCHomeMiddleViewOnline:
            //在线预约
        {
            AppDelegate *app = (AppDelegate *)[[UIApplication  sharedApplication] delegate];
            [app.rootVC selectedIndexPath:102];
        }
            break;
        case HCHomeMiddleViewMessages:
            //消息中心
            //            [self pushChildrenViewController:@"HCMessageCenterViewController" parameterObject:nil dataObject:nil];
        {
            //            if (![PublicFunction isNull:HCGETUSER(@"hcvip")]) {
            //                if ([[NSString stringWithFormat:@"%@",HCGETUSER(@"hcvip")] isEqualToString:@"yes"]) {
            [self pushChildrenViewController:@"HCMessageCenterViewController" parameterObject:nil dataObject:nil];
            //                }else{
            //                    [XHToast showBottomWithText:@"请升级为会员"];
            //                }
            //            }
        }
            break;
        default:
            break;
    }
}

#pragma mark -- HCSanimationViewClicked 新闻中心点击事件
-(void)animationViewClicked:(NSInteger)index {
    HCHomeNewsData *data = newsModel.index[index];
    [self pushChildrenViewController:@"HCNeswDetailViewController" parameterObject:data.url dataObject:nil];
}

- (void)clickNewsImage {

    [self pushChildrenViewController:@"HCNewsCenterDetailController" parameterObject:nil dataObject:nil];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
